import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/**
 * @Description: 水印组件
 * @Author: 下雨了
 * @CreateDate: 2022-07-28 16:05
 * @UpdateUser: 更新者
 * @UpdateDate:  2022-07-28 16:05
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
///
class Watermark extends StatelessWidget {
  final int rowCount;
  final int columnCount;
  final String text;
  final TextStyle? textStyle;

  const Watermark({
    Key? key,
    this.rowCount = 3,
    this.columnCount = 6,
    required this.text,
    this.textStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return IgnorePointer(
      child: Container(
        child: Column(
          children: createColumnWidget(),
        ),
      ),
    );
  }

  List<Widget> createRowWidget() {
    List<Widget> list = [];
    for (var i = 0; i < rowCount; i++) {
      final widget = Expanded(
        child: Center(
          child: Transform.rotate(
            angle: -pi / 10,
            child: Text(
              text,
              style: textStyle ??
                  TextStyle(
                    color: Color(0x08000000),
                    fontSize: 18.r,
                    decoration: TextDecoration.none,
                    height: 1.0
                  ),
            ),
          ),
        ),
      );
      list.add(widget);
    }
    return list;
  }

  List<Widget> createColumnWidget() {
    List<Widget> list = [];
    for (var i = 0; i < columnCount; i++) {
      final widget = Expanded(
        child: Row(
          children: createRowWidget(),
        ),
      );
      list.add(widget);
    }
    return list;
  }
}
